/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.synjones.pay.serv.recharge.controller;

import com.synjones.core.util.RequestUtil;
import com.synjones.pay.model.recharge.RechargeReqBean;
import com.synjones.pay.model.recharge.RechargeRespBean;
import com.synjones.pay.serv.recharge.service.IRechargeNoticeReceiverService;
import com.synjones.pay.serv.recharge.service.IRechargeService;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author hsd
 */
@RestController
public class RechargeController {

    private final static Logger logger = LoggerFactory.getLogger(RechargeController.class);

    @Resource
    private IRechargeService rechargeService;
    
    @Resource
    private IRechargeNoticeReceiverService rechargeNoticeReceiverService;

    @RequestMapping(value = "/payment/recharge")
    public RechargeRespBean rechargePay(@RequestBody RechargeReqBean reqBean) {
        logger.info("充值信息：\r\n {}", ReflectionToStringBuilder.toString(reqBean, ToStringStyle.MULTI_LINE_STYLE));
        return rechargeService.tradeProcess(reqBean);
    }
    
    @RequestMapping(value = "/wis/backReceiver")
    public String rechargeBackstage(HttpServletRequest req){
        Map<String, String> reqMap = RequestUtil.getParameterMap(req);
        rechargeNoticeReceiverService.processNoticeData(reqMap);
        return "0";
    }
    
    @RequestMapping(value = "/wis/frontReceiver")
    public RechargeRespBean rechargeFrontStage(HttpServletRequest req){
        Map<String, String> reqMap = RequestUtil.getParameterMap(req);
        return rechargeNoticeReceiverService.processFrontNotice(reqMap);
    }
    
}
